package com.xinyu.service.impl;

import com.xinyu.domain.User;
import com.xinyu.mapper.UserMapper;
import com.xinyu.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xinyu.vo.BaseResult;
import com.xinyu.vo.UserRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author XinYu
 * @since 2025-02-17
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User findByPhone(String phone) {
        return userMapper.findByPhone(phone);
    }

    @Override
    public BaseResult queryByCondition(UserRequest userRequest) {
        List<User> list = userMapper.queryByCondition(userRequest);
        Integer userCounts = userMapper.countUsers(userRequest);
        return BaseResult.ok(list,userCounts);
    }
}
